/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

(function($){
    $('.drag').drag();
    $("body").find("#reg-vilid-form").validate({
        submitHandler: function(form) {
            $("#sub-login-reg-btn").attr("disabled","disabled").css("cursor","not-allowed").val("正在注册中...");;
            var data = $(form).serialize();
            doRequest("",data,true,function(B){
                window.location.href = B.redirectURL;
            },function(B){
                layer.msg(B.errorMsg,{time:2000,offset:300,icon:0});
                $("#sub-login-reg-btn").removeAttr("disabled").css("cursor","pointer").val("重新注册");
                return reload_check();
            });
        },
        rules:{
            regName:{isUserName:true,remote:{
                        type:"POST",
                        url:"/site/checkusersign"}},
            regPass:{isPwd:true},
            reregPass:{equalTo:"#regPass"},
            dragInput :"required",
        },		
        messages:{
            regName:{required:"请输入用户名",remote:"用户名已被注册"},
            regPass:{required:"请输入密码"},
            reregPass:{required:"请再次输入您的密码",equalTo:"密码不一致，请再次确认"},
            dragInput :"滑动滑块解锁"
        },
        errorPlacement: function(error,element)
        {
            error.appendTo ( element.parent() );
            error.addClass('error');
        },	
        success: function(label) {
            label.remove();
        }
    });
    $(".register-con .p20 ul li").on("click",function(){
        $("input",this).css("border","1px solid #1c273d");
        $(this).siblings().find("input").css("border-color","#e0e0e0");
    });
    
})(jQuery);


var reload_check = function(){
    $("#checkCode").attr("disabled","disabled");
    $("#dragInput").removeAttr("checked");
    $(".drag").html("<span class='cload'></span>");//加载动画
    setTimeout(function(){
        doRequest("/account/set_reg_key",{stamptime:Math.random()},true,function(B){
        $("#checkCode").val(B.key);
        $(".drag").html("");
        $(".drag").drag();
    },function(B){});
    },1000);
}